//! @file   lc_condition_variable.h
//! @brief  
//! @author Sayan Chaliha
//! @date   September, 2011
//!
//! 
#ifndef _LC_CONDITION_VARIABLE_H
#define _LC_CONDITION_VARIABLE_H

#include "libcyan_internal.h"
#include "lc_mutex.h"
#include "lc_types.h"
#include "lc_interval.h"
#include "lc_object.h"

namespace cyan {
    class CYAN_API ConditionVariable : public Object {
    public:
        ConditionVariable(Mutex&);
        virtual ~ConditionVariable();
        
        void notify();
        void notifyAll();
        Bool wait(const Interval&);
        
    private:
        ConditionVariable() {
        }
        
        ConditionVariable(const ConditionVariable&) {
        }
        
        void CYAN_HIDDEN wait_();
        Bool CYAN_HIDDEN timedWait_(Time);
        
        Mutex* lock_;
        ConditionVariableType condtionVariable_;
    };
    
    class CYAN_API Strobe : public Object {
    public:
        Strobe();
        virtual ~Strobe();

        Bool wait(const Interval&);
        void notify();
        void notifyAll();
        void reset();
        
    private:
        Strobe(const Strobe&) : conditionVariable_(mutex_) {
        }
        
        Bool isSignalled_;
        Mutex mutex_;
        ConditionVariable conditionVariable_;
    };
}

#endif /* _LC_CONDITION_VARIABLE_H */
